package com.shukesmart.speech.db;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.shukesmart.speech.R;

import java.util.List;

public class NoteAdapter  extends ArrayAdapter<NoteBean> {
    private int resourceId;
    public NoteAdapter(@NonNull Context context, int resource, List<NoteBean> brothers) {
        super(context, resource,brothers);
        Log.i("devices", String.valueOf(brothers));
        this.resourceId = resource;
    }
    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        NoteBean brother = getItem(position);
        Log.i("brother", String.valueOf(brother));
        View view;
        view = convertView;
        if (view==null){
            view = LayoutInflater.from(getContext()).inflate(this.resourceId,null);}
        TextView noteTile = view.findViewById(R.id.note_title);
        TextView noteContext = view.findViewById(R.id.note_content);
        TextView noteDate = view.findViewById(R.id.note_date);
        if (noteTile != null) {
            noteTile.setText(brother.getTitle());

        }
        if (noteContext != null) {
            noteContext.setText(brother.getContext());

        }

        if (noteDate != null) {
            noteDate.setText(brother.getCreateDate());

        }


        return view;
    }
}
